﻿using System;
using System.Reflection;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web.Routing;
using HashFoo.Rest.Server;
using HashFoo.Rest.ServerTests.FakeHttpStack;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace HashFoo.Rest.ServerTests
{
    [TestClass]
    public class ServiceHandlerUtilTests
    {
        [TestMethod]
        public void finds_all_service_handler_implementations_of_an_assembly()
        {
            var assembly = GetType().Assembly;

            var handlers = ServiceHandlerUtil.GetServiceHandlerImplementations(assembly).ToArray();

            Assert.AreEqual(1, handlers.Length);
            Assert.AreEqual(typeof(MockResources.ServiceHandlerMock), handlers.ElementAt(0));
        }

        [TestMethod]
        public void finds_all_interfaces_of_handler_type()
        {
            var handlerType = typeof(MockResources.ServiceHandlerMock);

            var interfaces = ServiceHandlerUtil.GetServiceHanlderInterfaces(handlerType).ToArray();

            Assert.AreEqual(1, interfaces.Length);
        }
    }
}
